home *** CD-ROM | disk | FTP | other *** search
- Path: Belgium.EU.net!news
- From: Christ.Vandromme@ping.be (Christ Vandromme)
- Newsgroups: comp.lang.c
- Subject: Re: Nee help with a string and temp string
- Date: Wed, 17 Apr 1996 21:03:30 GMT
- Organization: EUnet Belgium, Leuven, Belgium
- Message-ID: <4l3j65$gr5@news.Belgium.EU.net>
- References: <316C72CC.763A@cloudnet.com>
- NNTP-Posting-Host: dialup19.kortrijk.eunet.be
- X-Newsreader: Forte Free Agent 1.0.82
-
- "Randall J. Pfeifer" <rpfeifer@cloudnet.com> wrote:
-
- > I am writing a program that reads data, validates it, and then writes it to a new file.
-
- > My problem involves evaluating the second line. The program works like this.
-
- [snip]
-
- > void examineBcard()
- > { int result;
- >
-
- Here lies your problem....
- > strncpy(Bcard, "B", 1);
-
- strncpy only copies 1 character, it does NOT ADD a '\0'.
-
- So Add the folowing line:
-
- Bcard[1] = '\0';
-
- or
-
- in stead of strncpy use strcpy as follows:
- strcpy(Bcard, "B");
-
- > strncat(Bcard,&line[1],1);
- > strncat(Bcard, Space,3);
-
- > padright(Bcard,5,7,3,3);
- > padright(Bcard,8,12,5,5);
- > padright(Bcard,13,18,6,6);
- > strncat(Bcard," ",1);
-
- > padright(Bcard,20,22,3,3);
- > padright(Bcard,23,27,5,5);
- > padright(Bcard,28,33,6,6);
- > strncat(Bcard," ",1);
-
- > padright(Bcard,35,37,3,3);
- > padright(Bcard,38,43,5,5);
- > padright(Bcard,43,48,6,6);
- > strncat(Bcard," ",1);
-
- > padright(Bcard,50,52,3,3);
- > padright(Bcard,53,57,5,5);
- > padright(Bcard,58,63,6,6);
- > strncat(Bcard," ",1);
-
- > padright(Bcard,65,67,3,3);
- > padright(Bcard,68,72,5,5);
- > padright(Bcard,73,78,6,6);
- > strncat(Bcard,"\n",1);
- >
- > fputs(Bcard,fpcardwrt);
- >
- > }
-
- Hope to have helped you,
-
- Christ Vandromme.
-
-
- ----------------------------------------------
- Email me at Christ.Vandromme@ping.be
-
- Home page: http://www.ping.be/user/Christ.Vandromme
-
-